package sort.ui.components;

import java.awt.Container;
import java.awt.GraphicsConfiguration;
import java.awt.GridLayout;
import java.awt.HeadlessException;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import sort.result.SortResult;

/**
 * @author masaru-gotou
 *
 */
@Deprecated
@SuppressWarnings("serial")
public class ResultListWindow extends JFrame {
	private JTable table;
	private ResultTableModel model;
	private JPanel v_panel;

	/**
	 * @param gc
	 */
	public ResultListWindow(GraphicsConfiguration gc) {
		super(gc);
		init_inner();
	}

	/**
	 * @param title
	 * @param gc
	 */
	public ResultListWindow(String title, GraphicsConfiguration gc) {
		super(title, gc);
		init_inner();
	}

	/**
	 * @param title
	 * @throws HeadlessException
	 */
	public ResultListWindow(String title) throws HeadlessException {
		super(title);
		init_inner();
	}

	/**
	 * 
	 *
	 */
	public ResultListWindow() {
		super();
		init_inner();
	}
	
	private void init_inner() {
//		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(100, 100);
		createComponents();
	}

	private void createComponents() {
		setLookAndFeel();
		
		Container container = getContentPane();
		
		v_panel = new JPanel(new GridLayout(1,0));
		container.add(v_panel);
		
        this.model = new ResultTableModel();
		this.table = new JTable(this.model);
        JScrollPane scrollPane = new JScrollPane(table);
        v_panel.add(scrollPane);
	}

	private void setLookAndFeel() {
//		try {
//			UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
//			SwingUtilities.updateComponentTreeUI(this);
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
	}

//	protected void writeLog(Log log, Records records) {
////		log.debug("recs="+records.size());
////		for (Record record : records) {
////			log.debug("rec"+record);
////		}
//		log.debug(records);
//	}

	public void addSortResult(SortResult result) {
		model.add(result);
	}

	public void addAllSortResult(List<SortResult> results) {
		model.addAll(results);
	}
}
